//验证码
s = 0;
function vcfunc1() {
    var x = Math.floor(Math.random()*10+1);
    var y = Math.floor(Math.random()*10+1);
    s = x + y;
    obj = document.getElementById('verifycode');
    obj.innerHTML = x + '+' + y + '=?';
}

function vcfunc2() {
    obj = document.getElementById('L_vercode');
    if (obj.value != s) {
        obj = document.getElementById('vcerr');
        obj.innerHTML = '验证码不正确！'
    }
}


function upload() {
    var obj = document.getElementById('uploadphoto');
    obj.click();
}

function douploadphoto() {
    photoform = document.getElementById('photoform');
    fd = new FormData(photoform);
    xhr = new XMLHttpRequest();
    xhr.open('post', '/user/uploadphoto/');
    xhr.send(fd);

    xhr.onreadystatechange = function () {
        if (xhr.readyState == 4) {
            if (xhr.status == 200 || xhr.status == 304) {
                ret = JSON.parse(xhr.responseText);
                obj = document.getElementById('photo');
                obj.src = ret.user_photo;

            }
        }
    }
}
